<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<title>FCRE2.1——监考</title>
<head th:include="include :: header"></head>
<style>
#minnum{    background: #FFFFFF none;
    border: 1px solid #e5e6e7;
    border-radius: 1px;
    color: inherit;
    height:30px;
    -webkit-transition: border-color 0.15s ease-in-out 0s, box-shadow 0.15s ease-in-out 0s;
    transition: border-color 0.15s ease-in-out 0s, box-shadow 0.15s ease-in-out 0s;
    font-size: 14px;
    width:35px;
    }
.kcstatusb{
    font-size: 16px;
    height: 22px;
    margin-left: 20px;
    color: #2e6da4;
} 
.kcstatusa{
	width:50px;
	font-size: 16px;
    vertical-align: bottom;
    text-align: left;
    color: #f00;
    border-bottom: 2px solid #00f;
    padding: 1px 5px;
} 
.kstitle{
	/* background: #FFF; */
    padding: 0px 10px 0px 20px;
    text-align: center;
    font-size: 30px;
    font-weight: bold;
    color: #03A9F4;
}     
</style>
<body class="gray-bg">
<div class="container-fluid">
	<div id="mynav" class="row-fluid">
		<div class="span12">
			<div class="navbar navbar-fixed-top" style="position: fixed;margin-bottom: 0;">
				<div class="navbar-inner">
					<div class="container-fluid">
					<div >
						<ul class="nav navbar-top-links navbar-right welcome-message">
						<li>
						<!--<div class="border-bottom kstitle" >
				            <span>[[${ksname}]]</span>
				        </div>-->
						</li>
	                    <li>
	                        <span class="text-muted">
	                        <th:block th:include="common :: datetime(${now0})" />
	                        </span>
	                    </li>
							<li>
								<a ><i class="fa fa-user"></i>[[${user.userName}]]</a>
							</li>
	                    <li><a id="backtotop"><i class="fa fa-refresh"></i>刷新</a></li>
                    	<li><a id="logout"><i class="fa fa-sign-out"></i>退出</a></li>
						</ul>
					</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>

     <div class="container-div" style="margin-top: 60px;">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="formId">
					<div class="select-list">
						<ul>
							<li>
								考号：<input type="text" name="uid" style="width:130px;" />
							</li>
							<!-- <li>
								<label class="check-box">
									<input name="ismiss" type="checkbox" value="1">未考
								</label>
							</li> -->
							<li>
								<!--<input type="hidden" name="ksid"  th:value="${ksid}" />-->
								<!--<input type="hidden" name="pc"  value="1" />-->
								<select id="pc"  name="pc" class="form-control noselect2 selectpicker" >
									<option value=""> -- 请选择批次 -- </option>
									<option th:each="pctime : ${pctimes}" th:value="${pctime.pc}" th:text="${pctime.pc}+'：'+${#dates.format(pctime.startTime,'MM.dd HH:mm')}+'-'+${#dates.format(pctime.endTime,'MM.dd HH:mm')}">
								</select>
							</li>
							<li>
								<th:block th:if="${#strings.contains(user.roleIds,',1,')}">
									<select id="ip"  name="ip" class="form-control noselect2 selectpicker" >
										<option value=""> -- 请选择考场 -- </option>
										<option th:each="kcroom : ${ksrooms}" th:value="${kcroom.ip}" th:text="${kcroom.kcname}">
									</select>
								</th:block>
							</li>
							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
			
							</li>
						</ul>
					</div>
				</form>
			</div>
		
	        <div class="btn-group-sm hidden-xs" id="toolbar" role="group">
				<a class="btn btn-info" onclick="$.table.refresh()" shiro:hasPermission="exam:exarrange:kcmgr">
					<i class="fa fa-refresh"></i> 刷新
				</a>
				<a class="btn btn-primary" onclick="goadduser()" shiro:hasPermission="exam:exarrange:kcmgr">
					<i class="fa fa-edit"></i> 考生管理
				</a>
				<a class="btn btn-primary btn-edit disabled" onclick="doedit(1)" shiro:hasPermission="exam:exarrange:kcmgr">
					<i class="fa fa-desktop"></i> 查看密码
				</a>
				<a class="btn btn-primary" onclick="doedit(2)" shiro:hasPermission="exam:exarrange:kcmgr">
					<i class="fa fa-desktop"></i> 换机
				</a>
				<a class="btn btn-danger" onclick="doedit(3)" shiro:hasPermission="exam:exarrange:kcmgr">
					<i class="fa fa-repeat"></i> 重考
				</a>
				<a class="btn btn-warning " onclick="doedit(4)" shiro:hasPermission="exam:exarrange:kcmgr">
						<i class="fa fa-clock-o"></i> 补时
				 </a>
				 <input id="minnum" name="minnum" value="0" type="text">分钟
				 <div style="float: right;">
				 		<b class="kcstatusb">待考：</b>
						<b class="kcstatusa" id="mytotalkswait">0</b>
						<b  class="kcstatusb">在考：</b>
						<b class="kcstatusa" id="mytotalksing">0</b>
						<b  class="kcstatusb">已交卷：</b>
						<b class="kcstatusa" id="mytotalksed">0</b>
						<b  class="kcstatusb">异常：</b>
						<b class="kcstatusa" id="mytotalkserr">0</b>
				 
				 </div>
			</div>
			<!-- <div class="col-sm-12 search-collapse">
			<b style="font-size: 16px;">待考：</b>
			<a class="btn btn-primary btn-xs " id="mytotalkswait" href="#" >0</a>
			<b style="font-size: 16px;">在考：</b>
			<a class="btn btn-warning btn-xs " id="mytotalksing" href="#" >0</a>
			<b style="font-size: 16px;">已交卷：</b>
			<a class="btn btn-success btn-xs " id="mytotalksed" href="#" >0</a>
			<b style="font-size: 16px;">异常：</b>
			<a class="btn btn-danger btn-xs " id="mytotalkserr" href="#" >0</a>
			</div> -->
			<div class="col-sm-12 select-table table-striped">
				<table id="bootstrap-table" data-mobile-responsive="true" style="table-layout: fixed;"></table>
			</div>
		</div>
	</div>
    <div th:include="include :: footer"></div>
        <script th:src="@{/assets/js/timecountdown.min.js}"></script>
    <script>
    var now0=Date.parse("[[${now0}]]".replace(/-/g,"/"));
    $(function(){
    	xcsoft.counter("[[${now0}]]",function (time) {
    		document.getElementById("y4").innerHTML=time.year
            document.getElementById("m4").innerHTML=time.monthZero
            document.getElementById("d4").innerHTML=time.dayZero
            document.getElementById("h4").innerHTML=time.hourZero
            document.getElementById("i4").innerHTML=time.minuteZero
            document.getElementById("s4").innerHTML=time.secondZero
        });
    	$('#backtotop').click(function(){
    		window.location.reload();
    	});
    	$('#logout').click(function(){
    		window.location.href="/login/kdlogout";
    	})
    })
    </script>
    <script th:inline="javascript">
        var prefix = ctx + "exam/exarrange";
        
        $(function() {
            var options = {
                url: prefix + "/listip",
                modalName: "考场",
                //queryParams:$('#formId').serialize(),//{"ksid":[[${ksid}]]},覆盖原生的查询参数了
				search: false,
		        showExport: false,
		        sortOrder : "desc",
				sortName : "signintime",
				pageSize:100,
				striped:true,
				//showFooter:true,
                columns: [{
		            checkbox: true
		        },
		        {
					field : 'id', 
					title : '编号',
					visible:false
				},
				{
					field : 'status', 
					title : '状态',
					sortable: true,
					formatter: function(value, row, index) {
		            	var actions = [];
						if(value==0)actions.push('<a class="btn btn-default btn-xs " href="#" >待考</a>');
		            	else if(value==4)actions.push('<a class="btn btn-primary btn-xs " href="#" >在考</a>');
		            	else if(value==8)actions.push('<a class="btn btn-success btn-xs " href="#" >交卷</a>');
						else actions.push('<a class="btn btn-danger btn-xs " href="#" >异常</a>');
		            	return actions.join('');
					},
					/* footerFormatter: function (value) { 
						var ksing = 0,ksed=0,kserr=0,kswait=0; 
						for (var i in value) { 
							if(value[i].status==0) kswait++;
							else if(value[i].status==4) ksing++;
							else if(value[i].status==8) ksed++;
							else if(value[i].status==9) kserr++;
						} 
						$("#mytotalkswait").text(kswait);
						$("#mytotalksing").text(ksing);
						$("#mytotalksed").text(ksed);
						$("#mytotalkserr").text(kserr);
					}, */
					width:80
				},
				{
					field : 'user.classg', 
					title : '班级',
					width:120
				},
				{
					field : 'uid', 
					title : '考生号',
					width:120
				},
				{
					field : 'user.userName', 
					title : '姓名',
					width:120
				},
				{
					field : 'loginip2', 
					title : '登录IP',
					width:130
				},
				{
					field : 'macaddr', 
					title : '机器MAC',
					width:140
				},
				{
					field : 'signintime', 
					title : '首次进入时间',
					width:140
				},
				{
					field : 'udtime', 
					title : '已考时长<br>(分钟)',
					width:100
				},
				
				{
					field : 'jjtime', 
					title : '交卷时间'
				}],
				responseHandler:function(data){
					$("#mytotalkswait").text(data.t1);
					$("#mytotalksing").text(data.t2);
					$("#mytotalksed").text(data.t3);
					$("#mytotalkserr").text(data.t4);
				}
            };
            $.table.init(options);
        });
        function goadduser(){
        	$.modal.open("考生管理",ctx+"exam/exarrange/kduser");
        } 

function doedit(n){
	var rows = $.common.isEmpty(table.options.uniqueId) ? $.table.selectFirstColumns() : $.table.selectColumns(table.options.uniqueId);
	if(rows.length==0){
		$.modal.alertWarning("需选择考生");
		return;
	};
	var m=rows.length;
	if(n==3){
		$.modal.confirm3("重考，是取消已交卷考生的成绩！！！\r\n你确定要为选中的"+m+"个考生设置重考吗？",function(){
			$.operate.post(prefix + "/doedit/"+n,{"minnum":0,"ids": rows.join()});
		},function(){return;});
	}else if(n==4){
		var minnum=parseInt($("#minnum").val());
		if((isNaN(minnum) || minnum==0)){
			$.modal.alertWarning("补时需要设置大于0的分钟数");
			return;
		};
		$.operate.post(prefix + "/doedit/"+n,{"minnum":minnum,"ids": rows.join()});
	}else
		$.operate.post(prefix + "/doedit/"+n,{"minnum":0,"ids": rows.join()});
}        
    </script>
</body>
</html>